package org.jeecg.modules.system.service.impl;

import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import org.jeecg.common.system.base.service.impl.JeecgServiceImpl;
import org.jeecg.modules.system.entity.BizOutbound;
import org.jeecg.modules.system.entity.BizOutboundProduct;
import org.jeecg.modules.system.mapper.BizOutboundMapper;
import org.jeecg.modules.system.service.IBizOutboundProductService;
import org.jeecg.modules.system.service.IBizOutboundService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import java.beans.Transient;

/**
 * @Description: 出库
 * @Author: jeecg-boot
 * @Date:   2024-02-01
 * @Version: V1.0
 */
@Service
public class BizOutboundServiceImpl extends JeecgServiceImpl<BizOutboundMapper, BizOutbound> implements IBizOutboundService {

    @Autowired
    IBizOutboundProductService bizOutboundProductService;

    @Override
    @Transactional
    public boolean save(BizOutbound bizOutbound) {

        bizOutbound.setId(IdWorker.getIdStr());


        baseMapper.insert(bizOutbound);

        if(bizOutbound.getList()!=null&&bizOutbound.getList().size()>0){
            for (BizOutboundProduct item : bizOutbound.getList()) {
                item.setOutboundId(bizOutbound.getId());
                bizOutboundProductService.save(item);
            }
        }

        return true;
    }
}
